<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加商品</title>
    <style>
        div{
            text-align: center;
            background-color: beige;
            margin: 0 auto;
            padding: 30px;
        }
        input[type="text"]{
            width: 500px;
            height: 50px;
            margin-top: 6px;
        }
    </style>
</head>
<body>

<div>
    <h1>添加商品</h1>
  <input type="text" v-model="product.title" placeholder="商品标题"><br>
  <input type="text" v-model="product.price" placeholder="商品价格"><br>
  <input type="text" v-model="product.saleCount" placeholder="商品销量"><br>
  <input style="height: 50px;width: 100px;margin-top: 20px" type="button" value="添加" @click="insert()">
</div>

<script src="js/vue.js"></script>
<script src="js/axios.min.js"></script>

<script>
  let v = new Vue({
    el:"div",
    data:{
      product:{title:"",price:"",saleCount:""}
    },
    methods:{
      insert(){
          axios.post("/insert",v.product).then(function (response){
            alert("添加成功!");
            location.href="/";
          })
      }
    }
  })
</script>
</body>
</html>